{extend name='admin@main'}

{block name="button"}

{if auth("add")}
<!-- <button data-modal='{:url("add")}' data-title="添加访客信息" class='layui-btn layui-btn-sm layui-btn-primary'>添加访客信息</button> -->
{/if}

{if auth("remove") && ($userinfo['db2']['roleid'] == 1 || $userinfo['db1']['roleid'] == 1)}
<!-- <button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除这些信息吗？" action="{:url('department/remove')}" class='layui-btn layui-btn-sm layui-btn-primary'>删除访客信息</button> -->
{/if}

{/block}

{block name="content"}
{php}
{//var_dump($userinfo['db1']);}
{//var_dump($list);}
{/php}
<div class="think-box-shadow">
    {include file='visitor/index_search'}
    <table class="layui-table" lay-skin="line">
        {notempty name='list'}
        <thead>
        {if $userinfo['db1']['authorize'] ==1}
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>

            <th class='list-table-sort-td'>
                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
            </th>
            <th class='text-left nowrap'>访客姓名</th>
            <th class='text-left nowrap'>访客性别</th>
            <th class='text-left nowrap'>访客联系</th>
<!--             <th class='text-left nowrap'>所属公司</th>
            <th class='text-left nowrap'>所属部门</th> -->
            <th class='text-left nowrap'>操作选项</th>
        </tr>
         {/if}
         {if $userinfo['db1']['authorize'] == 8}
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>

            <th class='list-table-sort-td'>
                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
            </th>
            <th class='text-left nowrap'>访客姓名</th>

            <th class='text-left nowrap' style="width: 10px;">访客性别</th>
            <th class='text-left nowrap'>访客联系</th>
<!--             {if $userinfo['db1']['authorize'] == 1 || $userinfo['db1']['authorize'] == 8}
            <th class='text-left nowrap'>拜访公司</th>
            {/if}
            <th class='text-left nowrap'>拜访部门</th>
            <th class='text-left nowrap'>接见员工</th>
            <th class='text-center nowrap'>到访状态</th>
            {if $userinfo['db1']['authorize'] == 2}
            <th class='text-left nowrap'>预约拜访时间</th>
            {/if} -->
            <th class='text-left nowrap'>操作选项</th>
        </tr>
       {/if}

         {if $userinfo['db1']['authorize'] == 2 || $userinfo['db1']['authorize'] == 3 || $userinfo['db1']['authorize'] == 4}
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>

            <th class='list-table-sort-td'>
                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
            </th>
            <th class='text-left nowrap'>访客姓名</th>
            <th class='text-left nowrap'>访客性别</th>
            <th class='text-left nowrap'>访客联系</th>
<!--             {if $userinfo['db1']['authorize'] == 1 || $userinfo['db1']['authorize'] == 8}
            <th class='text-left nowrap'>拜访公司</th>
            {/if}
            <th class='text-left nowrap'>拜访部门</th>
            <th class='text-left nowrap'>接见员工</th>
            <th class='text-center nowrap'>到访状态</th>
            {if $userinfo['db1']['authorize'] == 2}
            <th class='text-left nowrap'>预约拜访时间</th>
            {/if} -->
            <th class='text-left nowrap'>上次来访时间</th>
            <th class='text-left nowrap'>操作选项</th>
        </tr>
       {/if}

        </thead>
        {/notempty}
        <tbody>
        <!-- //管理员 -->
        {if $userinfo['db1']['authorize'] ==1}
        {foreach $list as $key=>$vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
            <td class='list-table-sort-td'>
            {$vo.id}
            </td>
            <td class='text-left nowrap'>

                {$o.personimg}

                {notempty name='vo.personimg'}
                <img data-tips-image style="width:40px;height:40px;border-radius: 50%;" src="{$vo.personimg|default=''}" class="margin-right-5 text-top">
                {/notempty}
                {$vo.name|default='用户数据丢失'}


            </td>
            <td class='text-left nowrap'>
                
                {switch name="vo.sex" }
                    {case value='0'}&nbsp;&nbsp;&nbsp;&nbsp;未知{/case}
                    {case value='1'}&nbsp;&nbsp;&nbsp;&nbsp;男{/case}
                    {case value='2'}&nbsp;&nbsp;&nbsp;&nbsp;女{/case}
                    {default  /}-
                {/switch}
            </td>
            <td class='text-left nowrap'>{$vo.mobile}</td>

            <!-- <td class='text-left nowrap'>{$vo.company_name|default='-'}</td>
            <td class='text-left nowrap'>{$vo.dept_name|default='-'}</td> -->
           <!--  <td class='text-left nowrap'>{$vo.role_name|default='-'}</td> -->

            <td class='text-left nowrap'>

                {if auth("edit")}
               <!--  <a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑访客信息" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a> -->
                {/if}
                {if auth("details")}
                <button data-modal='{:url("details")}?userid={$vo.id}' data-title="查看访问记录" class='layui-btn layui-btn-sm layui-btn-green'>查看访问记录</button>
                {/if}
            </td>
        </tr>
        {/foreach}
       <!--  //其他角色 -->
         {else}
                 {foreach $list as $key=>$vo}
        <tr data-dbclick>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
            <td class='list-table-sort-td'>
            {$vo.id}
            </td>
            <td class='text-left nowrap'>
                {notempty name='vo.vister_personimg'}
                <img data-tips-image style="width:40px;height:40px;border-radius: 50%;" src="http://devs.zsicp.com/public/upload/person/{$vo.vister_personimg|default=''}" class="margin-right-5 text-top">
                {/notempty}
                {$vo.vister_name|default='用户数据丢失'}

        </td>
             {if $userinfo['db1']['authorize'] == 1 || $userinfo['db1']['authorize'] == 8}
            <td class='text-left nowrap'>{$vo.app_company_name|default='-'}</td>
            {/if}
            <td class='text-left nowrap'>

                {switch name="vo.vister_sex" }
                    {case value='0'}&nbsp;&nbsp;&nbsp;&nbsp;未知{/case}
                    {case value='1'}&nbsp;&nbsp;&nbsp;&nbsp;男{/case}
                    {case value='2'}&nbsp;&nbsp;&nbsp;&nbsp;女{/case}
                    {default  /}-
                {/switch}

            </td>
            <td class='text-left nowrap'>{$vo.vister_mobile|default='-'}</td>

             {if $userinfo['db1']['authorize'] == 2}

            <td class='text-left nowrap'>
                {$vo.vister_arrivetime|format_datetime|default="-"}
            </td>
            {/if}
            <td class='text-left nowrap'>
                {if auth("details")}
                 {if $userinfo['db1']['authorize'] == 8}
                    <button data-modal='{:url("details")}?userid={$vo.vister_uid}&vis_companyid={$vo.app_company_id}' data-title="查看访问记录" class='layui-btn layui-btn-sm layui-btn-green'>查看访问记录</button>
                {else}
                    <button data-modal='{:url("details")}?userid={$vo.vister_uid}' data-title="查看访问记录" class='layui-btn layui-btn-sm layui-btn-green'>查看访问记录</button>
                 {/if}
                {/if}
                {if auth("edit")}
               <!--  <a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑访客信息" data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a> -->
                {/if}

                {if auth("state") and $vo.appointment_status neq 0}
<!--                 <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="arrive_id#{@$vo.arrive_id};app_id#{@$vo.appointmentid};meeting_id#{$vo.id};status#0" data-csrf="{:systoken('state')}">设为未到访</a> -->
                {elseif auth("state") and $vo.appointment_status neq 1 }
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="arrive_id#{$vo.arrive_id};app_id#{$vo.id};meeting_id#{$vo.meeting_id};status#1" data-csrf="{:systoken('state')}">设为已到访</a>
                {/if}

                {if auth("remove")}
                {if auth("state") and $vo.appointment_status neq 1 || auth("state") and $vo.appointment_status neq 2 || auth("state") and $vo.appointment_status neq 3}
                <!--  <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该访客的访问记录吗？" data-action="{:url('remove')}" data-value="companyid#{$vo.companyid};vister_uid#{$vo.vister_uid}" data-csrf="{:systoken('remove')}" action="{:url('user/remove')}">删除访客记录</a> -->
                {/if}

                {/if}

            </td>
        </tr>
        {/foreach}
         {/if}
        



        </tbody>
    </table>

<style type="text/css">
    .pagination{
        width: 100%
    }
    .pagination li{display: inline-block!important;margin: 10px;}
</style>
    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>

{/block}
